<!doctype html>
<html>

  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../css/1px.css" />
    <style>
      html {
        font-family: Roboto, Arial, "Noto Sans CJK SC", "Noto Sans CJK TC", "Pingfang SC", "Microsoft Yahei", "WenQuanYi Micro Hei", sans-serif;
      }
      
      body {
        overflow-x: hidden;
        background-color: #fff !important;
      }
      
      .mui-content {
        background-color: #fff;
      }
      /*商品详情*/
      
      .goods-each {
        font-size: 13px;
        line-height: 26px;
        position: relative;
        margin-top: 4px;
        background-color: rgba(228, 178, 61, 0.2);
      }
      
      .img-box {
        text-align: center;
      }
      
      .img-box img {
        height: 70px;
        width: 70px;
        vertical-align: middle;
      }
      
      .error-num {
        margin-right: 20px;
        color: red;
      }
      
      .reason-fix {
        height: 30px;
        line-height: 30px;
      }
      
      .fixed-num {
        margin-left: 5px;
      }
      .error2{
      	position: absolute;
      	bottom: 1px;
      	right: 5px;
      	color: red;
      }
      /**/
      
      .divider {
        padding: 5px 8px 6px;
      }
      
      .divider div {
        margin-top: 8px;
      }
      
      .divider p {
        text-align: center;
      }
      /**/
     .mui-scroll-wrapper {
        top: 110px;
        bottom: 4px;
      }
     /**/
      
      .error-each {
        line-height: 22px;
        font-size: 13px;
        padding: 6px;
        position: relative;
      }
      .bgGray{
      	background-color: #F8F8F8;
      }
      .type {
        float: right;
        margin-right: 20px;
      }
      .sn{
      	margin-left: 40px;
      }
      .span-error {
        color: red;
        position: absolute;
        top: 28px;
        right: 10px;
      }
       /*加载*/
      
      .mui-pull-bottom-pocket {
        visibility: visible;
      }
      
      .mui-pull-bottom-pocket .mui-pull-loading {
        visibility: visible;
      }
    </style>
  </head>

  <body>
    <div class="mui-content">
      <div class="goods-each vux-1px-b">
        <script id="goods" type="text/html">
          <div class="mui-row">
            <div class="img-box mui-col-xs-3">
              <img src="<%=imgPath+ list.shopGoodsVo.wareGoods.cutImg%>" alt="" />
            </div>
            <div class="goods-info-box mui-col-xs-9">
              <div class="goods-name">
                <%=list.shopGoodsVo.wareGoods.name%>
              </div>
              <div class="goods-id">
                货品ID：
                <%=list.shopGoodsVo.wareGoods.wareGoodsId%>
              </div>
              <div class="goods-num">
                当前门店库存：
                <%=list.shopGoodsVo.shopGoodsAmount.amount%>
              </div>

            </div>
          </div>
        </script>
      </div>
      <!---->
      <div class="mui-row divider">
        <div class="mui-col-xs-4 vux-1px-b"></div>
        <p class="mui-col-xs-4">清点误差</p>
        <div class="mui-col-xs-4 vux-1px-b"></div>
      </div>
      <!---->
      <div class="mui-scroll-wrapper">
      	<div class="error-list mui-scroll">
        <ul class="mui-table-view mui-table-view-chevron  error-info-list">
          <!--<li class="error-each">
      					<div>订单号:1233324422 <span class="type">退货操作</span></div>
      					<div class="span-error">退货失误：-1</div>
      					<div class="withdraw-people">退货人：浩林</div>
      					<div class="receive-people">收货人：asdf</div>
      		</li>-->
          <script id="infoList" type="text/html">
            <% for(var i =0;i<list.length;i++){%>
          	 <%if(i%2===0){%>
            		 <li class="error-each">
            	<%} else {%>
            		 <li class="error-each bgGray">
            	<%}%>
              <div >
              	 <span>机台编号：<%=list[i].storeDeviceNum%></span><span class="sn">SN:<%=list[i].deviceSn%></span>
              </div>
              <div>
              	
              </div>
              <div class="receive-people">清点人：
                <%=list[i].inventoryMan%>
              </div>
              <div class="span-error">
              	误差数量：<%=list[i].errorAmount%>
              </div>
              <div>
              	清点时间：<%=list[i].inventoryTime%>
              </div>
            </li>
            <%}%>
          </script>
        </ul>
        <!--加载中-->
          <div class="mui-pull-bottom-pocket">
            <div class="mui-pull">
            </div>
          </div>
          <!--加载中-->
      </div>
      </div>
      
    </div>
    <script src="../config.js"></script>
    <script src="../js/template-native.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/mui.min.js"></script>
    <script type="text/javascript">
      (function($) {
        $.init()
        $.plusReady(function() {
          receiveParams()
          bindEvent()
          getInfoList()
        })
       	
        var fromTime, fromTime, goodsInfo = {},
          Info = [],
          isLoading = false,
          pageTatol = 0,
          pageNo = 1,
          storeDeviceNum = ''
					//滚动
          $('.mui-scroll-wrapper').scroll({
            scrollY: true,
            bounce: true,
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006，
          });
        //接收传值
        function receiveParams() {
          var self = plus.webview.currentWebview();
          currentShopObj = self.currentShopObj;
          fromTime = self.fromTime
          toTime = self.toTime
          storeDeviceNum = self.storeDeviceNum
          goodsInfo = self.goodsInfo
          goodsErrorType = self.goodsErrorType
          setGoods()
        }
        //渲染商品
        function setGoods() {
          var html = template('goods', {
            list: goodsInfo,
            imgPath: config.imgPath,
          })
          $(".goods-each")[0].innerHTML = html
        }
         //设置加载状态
        function setLoading(type) {
          switch(type) {
            case 1:
              document.querySelector(".mui-pull").innerHTML = '<div class="mui-pull-loading mui-icon mui-spinner"></div>\
						<div class="mui-pull-caption">正在加载</div>'
              break
            case 2:
              document.querySelector(".mui-pull").innerHTML = '<div class="mui-pull-caption">没有更多</div>'
              break
            case 0:
              document.querySelector(".mui-pull").innerHTML = ''
              break
          }

        }
        //绑定事件
        function bindEvent(){
        	  	//滚动监听
        document.querySelector('.mui-scroll-wrapper').addEventListener('scrollend', function(e) {
          if(e.detail.y <= e.detail.maxScrollY) {
            if(isLoading === false) {
              if(++pageNo <= pageTatol) {
                getInfoList()
              } else {
								setLoading(2)
              }
            }
          }
        });
        }
        //请求数据
        function getInfoList() {
        	isLoading=true
        	setLoading(1)
          config.ajax({
            type: 'post',
            url: config.basePath + '/someErrorGoods/checkDeviceInfo',
            data: {
              storeId: currentShopObj.storeId,
              goodsId: goodsInfo.shopGoodsVo.wareGoods.wareGoodsId,
              fromTime: new Date(fromTime + ' 00:00:00').getTime(),
              toTime: new Date(toTime + ' 23:59:59').getTime(),
              storeDeviceNum: storeDeviceNum,
              pageNo:pageNo
            },
            success: function(res) {
              if(res.result === 1) {
              	pageTatol = res.info.pageTatol
                for(var k=0;k<res.info.data.length;k++){
                	Info.push(res.info.data[k])
                }
                setInfoList(Info)
                setLoading(0)
                isLoading = false
              } else {
              	if(Info.length===0){
              		setInfoList([])
              	}
              	$.toast(res.errormsg)
              	setLoading(0)
              }
            }
          })
        }
        //渲染列表
        function setInfoList(Info) {
          var listHtml = template('infoList', {
            list: Info
          })
          $(".error-info-list")[0].innerHTML = listHtml
        }
      }(mui))
    </script>
  </body>

</html>